<template>
    <div>
        <div class="head" style="height: 40px">
            <div style="width: auto;height: auto;overflow: hidden;float: left">
                <input type="text" class="form-control" style="width: 150px;float: left;margin-right: 10px" v-model="postData.msg" placeholder="请输入缩略词或含义">
                <button type="button" class="btn btn-primary" @click="query"><i class="glyphicon glyphicon-search"></i>查询</button>
                <button type="button" class="btn btn-default" @click="reset"><i class="glyphicon glyphicon-repeat"></i>重置</button>
            </div>
            <div style="float: right;overflow: hidden;">
                <button type="button" class="btn btn-primary" @click="queryData"><i class="glyphicon glyphicon-eye-open"></i>查看</button>
                <button type="button" class="btn btn-default" @click="addMsg"><i class="glyphicon glyphicon-plus"></i>新增</button>
                <button type="button" class="btn btn-default" @click="editData"><i class="glyphicon glyphicon-edit"></i>编辑</button>
                <button type="button" class="btn btn-default" @click="deleteData"><i class="glyphicon glyphicon-remove"></i>删除</button>
                <button type="button" class="btn btn-default" @click="deleteData2"><i class="glyphicon glyphicon-remove"></i>删除2</button>
                <button type="button" class="btn btn-default" @click="query2"><i class="glyphicon glyphicon-remove"></i>查询2</button>
                <button type="button" class="btn btn-default" @click="query3"><i class="glyphicon glyphicon-remove"></i>查询3</button>
            </div>
        </div>

        <div class="table-responsive">
            <table class="table table-striped table-hover table-bordered  max-width-table" id="editabledatatable"
                   style="table-layout:fixed !important" :showPagination="true">
                <thead>
                <tr role="row">
                    <th style="width: 50px;" class="text-center">
                    </th>
                    <th v-if="false" style="width: 100px; " class="text-center" data-field="field:ID,cssClass:text-left,hasTitle:true">
                        <label for="">id</label>
                    </th>
                    <th v-if="false" style="width: 100px; " class="text-center" data-field="field:Code,cssClass:text-left,hasTitle:true">
                        <label for="">编号</label>
                    </th>
                    <th style="width: 100px; " class="text-center" data-field="field:Price,cssClass:text-left,hasTitle:true">
                        <label for="">价格</label>
                    </th>
                    <th style="width: 100px; " class="text-center" data-field="field:Quantity,cssClass:text-left,hasTitle:true">
                        <label for="">数量</label>
                    </th>
                    <th style="width: 100px; " class="text-center" data-field="field:Creator,cssClass:text-left,hasTitle:true">
                        <label for="">创建人</label>
                    </th>
                    <th style="width: 200px; " class="text-center" data-field="field:CreateTime,cssClass:text-left,hasTitle:true">
                        <label for="">创建时间</label>
                    </th>
                    <th style="width: 100px; " class="text-center" data-field="field:LastModifier,cssClass:text-left,hasTitle:true">
                        <label for="">最后修改人</label>
                    </th>
                    <th style="width: 100px; " class="text-center" data-field="field:LastModifyTime,cssClass:text-left,hasTitle:true">
                        <label for="">最后修改时间</label>
                    </th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</template>
<script>
    export default {
        data() {
            return {
                test:"",
                condation:"",
                postData:{
                    msg:"",
                    method:"query",
                    ID:"",
                    page:"",
                    rows:"",
                    SID:"Demo-GetOrderAll"
                }
            }
        },
        mounted(){
            //定义表
            $("#editabledatatable").datagrid17({
                showPagination: true,
                url:" http://ttpsg.personaldev.teld/api/invoke",
                tableType: "single",
                maxRecordLimit: 10000,
                resizeCol: true,
                countPerPage: 10,
                PageSelectList: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 100],
                success: function (rData) {
                    console.log(rData)
                }
            }).data('bs.datagrid17');
            //执行查询
            this.query();
        },
        methods:{
            query:function(){
                var filter = {
                    "filter": this.postData
                };
                $("#editabledatatable").data('bs.datagrid17').searchByFilter({ searchCond: filter });
            },
            query3:function(){
                getDataAsync("http://localhost:8084/demo/hello","post",{"entity":JSON.stringify(this.postData)},function(data){
                    console.log(data)
                })
            },
            reset:function(){
                this.postData.msg="";
            },
            addMsg:function(){
                this.$router.push({path:'/WebPlatform/PackageMsgEdit',query: {method:"add"}})
            },
            queryData:function(){
                // console.log($("#editabledatatable").data('bs.datagrid17').getSelectedRowData().rowno)
                // $("#RoleTable").data('bs.datagrid17').getSelectedRowData();
                if($("#editabledatatable").data('bs.datagrid17').getSelectedRowData()==null){
                    this.$message({
                        message: '请选择一条记录',
                        type: 'warning'
                    });
                    return false;
                }
                this.$router.push({path:'/WebPlatform/PackageMsgEdit',
                    query: {
                        method:"watch",
                        // watchCdt:$("#editabledatatable").data('bs.datagrid17').getSelectedRowData().abb,
                        watchId:$("#editabledatatable").data('bs.datagrid17').getSelectedRowData().id,
                        // rowno:$("#editabledatatable").data('bs.datagrid17').getSelectedRowData().rowno
                    }})
            },
            editData:function(){
                if($("#editabledatatable").data('bs.datagrid17').getSelectedRowData()==null){
                    this.$message({
                        message: '请选择一条记录',
                        type: 'warning'
                    });
                    return false;
                }
                this.$router.push({path:'/WebPlatform/PackageMsgEdit',
                    query: {
                        method:"edit",
                        // watchCdt:$("#editabledatatable").data('bs.datagrid17').getSelectedRowData().abb,
                        watchId:$("#editabledatatable").data('bs.datagrid17').getSelectedRowData().id,
                        // rowno:$("#editabledatatable").data('bs.datagrid17').getSelectedRowData().rowno
                    }})
            },
            deleteData:function(){
                console.log($("#editabledatatable").data('bs.datagrid17').getSelectedRowData().ID)
                this.postData.method="delete"
                this.postData.ID=$("#editabledatatable").data('bs.datagrid17').getSelectedRowData().ID
                postData.SID="DeleteOrder"
                getDataAsync("http://ttpsg.personaldev.teld/api/invoke","post",{"filter":JSON.stringify(this.postData)},function(data){
                    console.log(data)
                })
                this.postData.method="query"
                this.query();
            },
            deleteData2:function(){
                getDataAsync("http://ttpsg.personaldev.teld/api/invoke?SID=DeleteOrder&id=2","get",null,function(data){
                    console.log(data)
                })
                this.query();
            },
            query2:function(){
                getDataAsync("http://ttpsg.personaldev.teld/api/invoke?SID=Demo-GetOrderAll&size=1&index=1 ","get",null,function(data){
                    console.log(data)
                })
                this.query();
            },
            query3:function(){
                var testData = {
                    SID:"Demo-GetOrderAll",
                    size:1,
                    index:1
                }
                getDataAsync("http://ttpsg.personaldev.teld/api/invoke","post",testData,function(data){
                    console.log(data)
                })
            },
        },
        created(){
            // console.log(this.$route.params.userId);
        }
    }
</script>